<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>创建新任务</title>

    <!-- Tailwind CSS via CDN -->
    <script src="https://cdn.tailwindcss.com"></script>

    <!-- Font Awesome via Cloudflare CDN -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />

    <style>
        /* Optional: Add custom base styles or component overrides here if needed */
        body {
            font-family: 'Inter', sans-serif; /* Example using a common sans-serif font */
        }
        /* Add focus ring styles for better accessibility */
        input:focus, textarea:focus, button:focus {
            outline: 2px solid transparent;
            outline-offset: 2px;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5); /* Tailwind's blue-500 focus ring */
        }
    </style>
    <!-- Consider adding a font like Inter from Google Fonts for better typography -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
</head>
<body class="bg-gradient-to-br from-gray-100 to-gray-200 min-h-screen flex flex-col">

    <!-- Header -->
    <header class="bg-white shadow-sm">
        <nav class="container mx-auto px-4 py-4 flex justify-between items-center">
            <div class="text-xl font-bold text-gray-800">
                <i class="fas fa-clipboard-list mr-2 text-blue-600"></i>任务管理器
            </div>
            <div>
                <!-- Navigation links can go here -->
                <a href="#" class="text-gray-600 hover:text-blue-600 px-3 py-2 rounded-md text-sm font-medium">查看任务</a>
                <a href="#" class="text-blue-600 hover:bg-blue-100 px-3 py-2 rounded-md text-sm font-medium border border-blue-600">登录</a>
            </div>
        </nav>
    </header>

    <!-- Main Content Area -->
    <main class="flex-grow container mx-auto px-4 py-8 md:py-12">
        <div class="max-w-3xl mx-auto bg-white p-6 md:p-8 rounded-xl shadow-lg">

            <h1 class="text-2xl md:text-3xl font-bold text-center text-gray-800 mb-6 md:mb-8">
                <i class="fas fa-plus-circle mr-2 text-green-500"></i>创建新任务
            </h1>

            <div class="grid grid-cols-1 md:grid-cols-3 gap-8">
                <!-- Form Section -->
                <div class="md:col-span-2">
                    <form id="create-task-form" class="space-y-6">
                        <!-- Task Title -->
                        <div>
                            <label for="task-title" class="block text-sm font-medium text-gray-700 mb-1">
                                <i class="fas fa-heading mr-1 text-gray-500"></i>任务标题 <span class="text-red-500">*</span>
                            </label>
                            <input type="text" id="task-title" name="task-title"
                                   class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 sm:text-sm transition duration-150 ease-in-out"
                                   placeholder="例如：完成项目报告"
                                   required>
                            <p id="title-error" class="text-red-500 text-xs mt-1 hidden">任务标题不能为空。</p>
                        </div>

                        <!-- Task Description -->
                        <div>
                            <label for="task-description" class="block text-sm font-medium text-gray-700 mb-1">
                                <i class="fas fa-align-left mr-1 text-gray-500"></i>任务描述
                            </label>
                            <textarea id="task-description" name="task-description" rows="5"
                                      class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 sm:text-sm transition duration-150 ease-in-out"
                                      placeholder="详细说明任务内容、步骤或要求..."></textarea>
                        </div>

                        <!-- Submit Button -->
                        <div class="flex justify-end pt-4">
                            <button type="submit"
                                    class="inline-flex items-center justify-center px-6 py-2 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition duration-150 ease-in-out">
                                <i class="fas fa-save mr-2"></i>
                                创建任务
                            </button>
                        </div>
                    </form>
                </div>

                <!-- Placeholder Image Section -->
                <div class="md:col-span-1 flex flex-col items-center mt-6 md:mt-0">
                     <h2 class="text-lg font-semibold text-gray-700 mb-3 text-center">
                        <i class="far fa-image mr-1 text-gray-500"></i>任务插图 (占位)
                     </h2>
                    <img src="https://fakeimg.pl/350x250/e2e8f0/94a3b8?text=Task+Visual&font=bebas"
                         alt="任务图片占位符"
                         class="rounded-lg shadow-md w-full max-w-xs md:max-w-full h-auto object-cover border border-gray-200">
                    <p class="text-xs text-gray-500 mt-2 text-center">这是一个图片占位符</p>
                     <!-- Or use Lorem Picsum: -->
                     <!-- <img src="https://picsum.photos/350/250" alt="随机任务图片" class="rounded-lg shadow-md w-full max-w-xs md:max-w-full h-auto object-cover border border-gray-200"> -->
                     <!-- <p class="text-xs text-gray-500 mt-2 text-center">来自 Lorem Picsum 的随机图片</p> -->
                </div>
            </div>
        </div>
    </main>

    <!-- Footer -->
    <footer class="bg-white mt-12 py-4 border-t border-gray-200">
        <div class="container mx-auto px-4 text-center text-gray-500 text-sm">
            &copy; 2023 任务管理系统. 保留所有权利.
        </div>
    </footer>

    <script>
        const form = document.getElementById('create-task-form');
        const titleInput = document.getElementById('task-title');
        const descriptionInput = document.getElementById('task-description');
        const titleError = document.getElementById('title-error');

        form.addEventListener('submit', function(event) {
            event.preventDefault(); // 阻止表单默认提交行为

            // --- 数据验证 ---
            let isValid = true;
            const title = titleInput.value.trim();
            const description = descriptionInput.value.trim();

            // 验证标题
            if (title === '') {
                titleError.classList.remove('hidden'); // 显示错误消息
                titleInput.classList.add('border-red-500'); // 添加红色边框
                titleInput.focus(); // 将焦点设置到标题输入框
                isValid = false;
            } else {
                titleError.classList.add('hidden'); // 隐藏错误消息
                titleInput.classList.remove('border-red-500'); // 移除红色边框
            }

            // 如果验证通过
            if (isValid) {
                console.log('--- 正在创建新任务 ---');
                console.log('标题:', title);
                console.log('描述:', description);

                // --- 模拟创建任务 ---
                // 在实际应用中，这里会发送数据到服务器
                // 例如使用 fetch API:
                /*
                fetch('/api/tasks', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({ title, description }),
                })
                .then(response => response.json())
                .then(data => {
                    console.log('任务创建成功:', data);
                    alert('任务创建成功！');
                    form.reset(); // 清空表单
                })
                .catch((error) => {
                    console.error('任务创建失败:', error);
                    alert('任务创建失败，请稍后重试。');
                });
                */

                // 模拟成功提示
                alert(`任务 "${title}" 创建成功！(信息已打印到控制台)`);

                // 可选：清空表单
                form.reset();
                titleInput.classList.remove('border-red-500');
                titleError.classList.add('hidden');

            } else {
                console.log('表单验证失败');
            }
        });

        // 当用户开始输入时，移除错误状态（可选，提升用户体验）
        titleInput.addEventListener('input', () => {
            if (titleInput.value.trim() !== '') {
                titleError.classList.add('hidden');
                titleInput.classList.remove('border-red-500');
            }
        });

    </script>

</body>
</html>
